<?php include load_template('_subnav.php') ?>
<style type="text/css" media="screen">
/* <![CDATA[ */
    #file_type_list {
        margin:5px auto;
        border:1px solid #eee;
        padding:2px;
    }
    #file_type_list form {
        display:inline;
    }
    .type_class {
        padding:2px;
        background:#edf3fe;
        margin:1px;
    }
    .description {
        color:#666;
        margin-left:20px;
    }
    .description b {
        color:#333;
    }
    
/* ]]> */
</style>
<h1>File Types</h1>
<div id='error_messages' class='flash_error' style='display:none'></div>
<p>Only files with the listed file types will be allowed on the server.</p>

<div id="add_new">
    <?php echo  form_remote_tag('add_file_type',
        array(
            'update'=>'file_type_list',
            'position'=>'Top',
            'scripts'=>true,
            'validation'=>true
            )
    ) ?>
    <b>Mime Type</b>
    <?php echo  text_field('types','mime',array('alt'=>'blank','emsg'=>'Please enter a mime type like images/jpg')) ?>
    <b>File Extention</b>
    <?php echo  text_field('types','ext',array('maxchars'=>4,'size'=>4,'alt'=>'length|3','emsg'=>'File extension can only be 3-4 characters with no "."')) ?>
    <b>Icon</b>
    <?php echo  select_tag('types[icon]',options_for_select( get_file_icons() )) ?>
    <?php echo  hidden_field_tag('action','add_file_type') ?>    
    <?php echo  submit_tag('add') ?>
    <?php echo  end_form_tag() ?>
    
</div>

<div id="file_type_list">
    <?php
        // file types
        foreach( $all_types as $type )
        {
            $form = form_remote_tag('delete_file_type').
                    hidden_field_tag('id',$type['id']).
                    hidden_field_tag('action','delete_file_type').
                    image_submit_tag('delete',get_installed_path().'/images/admin/delete.gif',array('onclick'=>"return delete_confirm('type_{$type['id']}')")).
                    end_form_tag();
            $image = !empty($type['icon']) ? "<img src='".get_installed_path()."/images/admin/icons/{$type['icon']}' />" : '';
            printf('<div id="type_%s" class="type_class">
                    %s
                    <b>%s</b>
                    <div class="description"><b>Ext:</b> %s &nbsp;&nbsp;&nbsp; %s %s</div>
                    </div>',
                    $type['id'],
                    $form,                        
                    $type['mime'],
                    $type['ext'],     
                    $image,               
                    $type['icon']
                    );
        }
    ?>
</div>
